Some computers include a graphics processing unit (GPU) which is a co-processor of a central processing unit. A graphics processing unit has a parallel processing architecture specifically designed to efficiently process graphics rendering operations, but also is applicable to similar kinds of operations that can be readily executed in parallel.
When a software developer creates an application for use on a computer with a GPU, an executable computer program is created. This executable computer program is generated for use on a particular type of computer with a combination of elements, typically called a platform, which includes the type of central processing unit, the type of graphics processing unit and the type of operating system. This executable program includes computer program code that can be executed by the GPU of that platform. Such an executable computer program would not run on another platform that is otherwise the same as the original platform, but has a different GPU, unless that different GPU had the same interfaces and instruction set as the GPU in the original platform.
Often, to address such a problem, the software developer may port an application to generate versions of the application that run on different platforms. However, porting does not assist end users who have a version of the application for one platform and who would like to use that version on another platform. For example, a game produced for one game console would not be executable on another game console unless that other game console incorporated the platform of the original game console in some way.
One way to incorporate the platform of a first computer in a second computer is to provide computer software on the second computer that emulates the platform of the first computer. When an application is executed on the second computer, if the application is determined to be an executable for the first computer, the second computer runs an emulator on its central processing unit which configures the second computer to provide interfaces to interact with the application in the same manner of the first computer, and translate commands and data between the application and the operating system, central processing unit and graphics processing unit of the second computer.
One challenge with emulating applications that use a graphics processing unit is the inclusion in such applications of small programs, called shaders, which are executed by the graphics processing unit. These shaders are executable code for an original GPU of the first computer, and need to be translated to be processed by a target GPU in the second computer. Generally, translating a shader is dependent upon a context in which the shader is called during execution of the application. Thus, shaders generally cannot be identified and translated statically prior to execution of the application. Other resources, e.g., graphics resources such as large textures, may have similar characteristics and are identified and processed during execution. Thus, such processing of resources is performed by the emulator during execution of the application, i.e., at “run time”. While results from processing resources at run time can be stored and re-used in a form of cache, an application can use a large number of shaders and other graphics resources. Processing such resources at run time can consume significant processor and memory resources, affecting performance of the application.